package com.yzh.openai.infrastructure.repository;

import com.yzh.openai.domain.auth.repository.IAuthRepository;
import com.yzh.openai.infrastructure.redis.IRedisService;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class AuthRepository implements IAuthRepository {
    private static final String Key = "wx_code";
    @Resource
    private IRedisService redisService;

    @Override
    public String getCode(String code) {
        return redisService.getValue(Key + "_" + code);
    }

    @Override
    public void removeCode(String code, String openid) {
        redisService.remove(Key + "_" + openid);
        redisService.remove(Key + "_" + code);
    }
}
